# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:张广勤
@Web site: https://www.tunan.wang
@Github:www.github.com
 
@File:concate1_0.py
@Time:2024/8/28 19:05

@Motto:不积跬步无以至千里，不积小流无以成江海！
"""
def join_with_underscore(items):
    # 使用join()方法拼接列表项，但首先需要将列表项转换为字符串
    # 如果列表为空，则直接返回空字符串
    if not items:
        return ""
    # 使用下划线作为分隔符来拼接列表项
    return "_".join(map(str, items))

# 测试代码
test_lists = [
    ["apple"],
    ["banana", "split"],
    ["cherry", "pie", "filling"]
]

for test_list in test_lists:
    print(f"Original list: {test_list}, Joined with underscore: {join_with_underscore(test_list)}")


test_list = ["工业增加值", "价格指数"]

print(f"Original list: {test_list}, Joined with underscore: {join_with_underscore(test_list)}")
